package engine.graphics.lighting
{
	import engine.math.*;
	
	public class RxDirectionalLight extends RxBaseLight
	{
		protected var m_direction:RxVector4;
		protected var m_ambient:RxVector4;
		
		public function RxDirectionalLight()
		{
			this.m_direction = new RxVector4(0, 0, -1, 0);
			this.m_ambient = new RxVector4(0, 0, 0, 0);
		}
		
		public function ParseFromXML(param1:XMLList) : void
		{
			var _loc_5:Number = NaN;
			var _loc_6:Number = NaN;
			var _loc_7:Number = NaN;
			var _loc_8:RxMatrix4x4 = null;
			var _loc_2:* = RxVector4.PoolAlloc();
			var _loc_3:uint = 16777215;
			var _loc_4:uint = 0;
			_loc_2.x = 0;
			_loc_2.y = 0;
			_loc_2.z = -1;
			_loc_2.w = 0;
			if (param1 != null && param1.length() != 0)
			{
				_loc_5 = Number(param1.@rotX);
				_loc_6 = Number(param1.@rotY);
				_loc_7 = Number(param1.@rotZ);
				_loc_3 = uint(param1.@diffuse);
				_loc_4 = uint(param1.@ambient);
				_loc_8 = RxMatrix4x4.PoolAlloc();
				_loc_8.RotateX(_loc_5 * (Math.PI / 180));
				_loc_8.PostMulRotateY(_loc_6 * (Math.PI / 180));
				_loc_8.PostMulRotateZ(_loc_7 * (Math.PI / 180));
				RxVector4.MulMatrix4x3(_loc_2, _loc_2, _loc_8);
				RxMatrix4x4.PoolFree(_loc_8);
				_loc_8 = null;
			}
			this.m_direction.x = -_loc_2.x;
			this.m_direction.y = -_loc_2.y;
			this.m_direction.z = -_loc_2.z;
			this.m_direction.w = 0;
			m_color.UnpackBGRA(_loc_3);
			this.m_ambient.UnpackBGRA(_loc_4);
			RxVector4.PoolFree(_loc_2);
			_loc_2 = null;
		}
	}
}